package com.linked.mystyle.food.serive.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.linked.mystyle.food.bean.FoodInfoPO;
import com.linked.mystyle.food.bean.FoodRandomParam;
import com.linked.mystyle.food.mapper.IFoodInfoMapper;
import com.linked.mystyle.food.serive.IFoodService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class FoodServiceImpl implements IFoodService {

    private final IFoodInfoMapper foodInfoMapper;

    public FoodServiceImpl(IFoodInfoMapper foodInfoMapper) {
        this.foodInfoMapper = foodInfoMapper;
    }

    @Override
    public boolean addFood(FoodInfoPO param) throws Exception {
        return foodInfoMapper.insert(param) > 0;
    }

    @Override
    public int queryFoodTotalCount(FoodRandomParam param) throws Exception {
        return foodInfoMapper.queryFoodTotalCount(param);
    }

    @Override
    public FoodInfoPO giveRandomFood(FoodRandomParam param, int foodNum) throws Exception {
        return foodInfoMapper.giveRandomFood(param,foodNum);
    }
}
